<template>
  <div>
    <a-form-model layout="inline" :model="searchform">
      <a-form-model-item>
        <a-input placeholder="case编号" style="width: 150px" v-model="searchform.caseNo"></a-input>
      </a-form-model-item>
      <a-form-model-item>
        <a-select placeholder="请选择case类型" v-model="searchform.caseType" style="width: 150px">
          <a-select-option v-for="(caseType, index) in caseTypeList" :key="index + 1">{{
            caseType.typeName
          }}</a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item>
        <a-select placeholder="请选择case状态" v-model="searchform.caseStatus" style="width: 150px">
          <a-select-option v-for="(caseStatus, index) in caseStatusList" :key="index + 1">{{
            caseStatus.statusName
          }}</a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item>
        <a-month-picker placeholder="请选择投产日期" style="width: 150px" v-model="searchform.operationDate" />
      </a-form-model-item>
      <a-form-model-item>
        <a-input placeholder="责任人" style="width: 150px" v-model="searchform.developPrincipal"></a-input>
      </a-form-model-item>
      <a-form-model-item :wrapper-col="{ span: 12, offset: 5 }">
        <a-button type="primary" icon="search" @click="handleSubmit">搜索</a-button>
      </a-form-model-item>
      <a-form-model-item :wrapper-col="{ span: 12, offset: 5 }">
        <a-button type="primary" icon="sync" @click="resetForm">重置</a-button>
      </a-form-model-item>
    </a-form-model>
  </div>
</template>

<script>
import { getCaseList } from '@/api/pf_bank/case/case'
export default {
  name: 'caseSearchHeader',
  props: {
    caseType: {
      type: Array
    },
    pageSize: {
      type: Number
    },
    caseStatus: {
      type: Array
    }
  },
  data() {
    return {
      size: this.pageSize,
      caseTypeList: this.caseType,
      caseStatusList: [],
      caseTypeList: [],
      searchform: {}
    }
  },
  watch: {
    caseType(newVal, oldVal) {
      this.caseTypeList = newVal
    },
    pageSize(newVal) {
      this.size = newVal
    },
    caseStatus(newVal, oldVal) {
      this.caseStatusList = newVal
    }
  },
  methods: {
    //搜索按钮
    handleSubmit() {
      getCaseList(1, this.size, this.searchform).then(res => {
        this.$emit('search', res.result)
      })
    },

    //重置按钮
    resetForm() {
      this.searchform = {}
      getCaseList(1, this.size, this.searchform).then(res => {
        this.$emit('reset', res.result)
      })
    }
  }
}
</script>

<style scoped lang="less">
@import '~@assets/less/common.less';
</style>
